﻿using System;
using UnityEngine;

namespace RootMotion.FinalIK
{
	// Token: 0x0200006E RID: 110
	[AddComponentMenu("Scripts/RootMotion.FinalIK/Rotation Limits/Rotation Limit Angle")]
	[HelpURL("http://www.root-motion.com/finalikdox/html/page12.html")]
	public class RotationLimitAngle : RotationLimit
	{
		// Token: 0x0600048C RID: 1164 RVA: 0x00004F07 File Offset: 0x00003107
		[ContextMenu("User Manual")]
		public void OpenUserManual()
		{
			Application.OpenURL("http://www.root-motion.com/finalikdox/html/page12.html");
		}

		// Token: 0x0600048D RID: 1165 RVA: 0x00004F13 File Offset: 0x00003113
		[ContextMenu("Scrpt Reference")]
		public void OpenScriptReference()
		{
			Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_rotation_limit_angle.html");
		}

		// Token: 0x0600048E RID: 1166 RVA: 0x00002E24 File Offset: 0x00001024
		[ContextMenu("Support Group")]
		public void SupportGroup()
		{
			Application.OpenURL("https://groups.google.com/forum/#!forum/final-ik");
		}

		// Token: 0x0600048F RID: 1167 RVA: 0x00002E30 File Offset: 0x00001030
		[ContextMenu("Asset Store Thread")]
		public void ASThread()
		{
			Application.OpenURL("http://forum.unity3d.com/threads/final-ik-full-body-ik-aim-look-at-fabrik-ccd-ik-1-0-released.222685/");
		}

		// Token: 0x06000490 RID: 1168 RVA: 0x000308E0 File Offset: 0x0002EAE0
		public override Quaternion LimitRotation(Quaternion rotation)
		{
			Quaternion rotation2 = this.LimitSwing(rotation);
			return RotationLimit.LimitTwist(rotation2, this.axis, base.secondaryAxis, this.twistLimit);
		}

		// Token: 0x06000491 RID: 1169 RVA: 0x00030910 File Offset: 0x0002EB10
		public Quaternion LimitSwing(Quaternion rotation)
		{
			if (this.axis == Vector3.zero)
			{
				return rotation;
			}
			if (rotation == Quaternion.identity)
			{
				return rotation;
			}
			if (this.limit >= 180f)
			{
				return rotation;
			}
			Vector3 vector = rotation * this.axis;
			Quaternion to = Quaternion.FromToRotation(this.axis, vector);
			Quaternion rotation2 = Quaternion.RotateTowards(Quaternion.identity, to, this.limit);
			Quaternion lhs = Quaternion.FromToRotation(vector, rotation2 * this.axis);
			return lhs * rotation;
		}

		// Token: 0x0400031F RID: 799
		[Range(0f, 180f)]
		public float limit = 45f;

		// Token: 0x04000320 RID: 800
		[Range(0f, 180f)]
		public float twistLimit = 180f;
	}
}
